/**
 * 
 */
package com.youth.fund.hk.hostManager.manager.dao.mybatis;

import java.sql.Timestamp;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.youth.fund.hk.hostManager.common.dao.mybatis.BaseMybatisDao;
import com.youth.fund.hk.hostManager.manager.dao.FlashDao;
import com.youth.fund.hk.hostManager.manager.datamodel.FlashModel;

/**
 * @author Sunk_Sky
 *
 * 2014年12月18日下午7:36:59
 */
@Repository("FlashDao")
public class FlashMybatisDaoImpl extends BaseMybatisDao<FlashModel, Integer> implements FlashDao
{
	private final static String CREATE = "flash.create";

	private final static String DELETE = "flash.delete";

	private final static String UPDATE = "flash.update";
	
	private final static String UPDATE_AVAILABLE = "flash.update_available";

	private final static String QUERY_BY_CONDITION = "flash.list_by_condition";
	@Override
	public boolean create(FlashModel model)
	{
		Timestamp timestamp = new Timestamp(System.currentTimeMillis());

		model.setSetup_time(timestamp);

		model.setUpdate_time(timestamp);

		return super.create(model, CREATE);
	}

	@Override
	public boolean delete(FlashModel model)
	{
		return super.delete(model, DELETE);
	}

	@Override
	public boolean update(FlashModel model)
	{
		Timestamp timestamp = new Timestamp(System.currentTimeMillis());

		model.setUpdate_time(timestamp);
		
		return super.update(model, UPDATE);
	}

	@Override
	public List<FlashModel> query(FlashModel model)
	{
		return super.query(model, QUERY_BY_CONDITION);
	}

	@Override
	public FlashModel queryOne(FlashModel model)
	{
		return super.queryOne(model, QUERY_BY_CONDITION);
	}

	@Override
	public boolean setAvailable()
	{
		boolean result = false;
		
		int temp = this.sqlSesstion.update(UPDATE_AVAILABLE);
		
		if(temp > 0 )
		{
			result = true;
		}
		return result;
	}

}
